package com.cn.wanxi.service;

import com.cn.wanxi.IO.FileModelIO;
import com.cn.wanxi.IOModel.CompanyIOModel;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.util.IOUtil;

public class CompanyService {
    public CompanyModel getCompany(){
        String path = IOUtil.COMPANYPATH.getPath();//存储和读取的文件地址
        String str = new CompanyIOModel().toString();
        FileModelIO.writeData(path,str);//写方法
        String result = FileModelIO.readData(path);//读方法
        String[] companyData = FileModelIO.inputData(result,IOUtil.SPILT.getPath());
        //封装数据到model类
        CompanyModel companyModel = new CompanyModel();
        companyModel.setLogo(companyData[2]);
        companyModel.setName(companyData[4]);
        companyModel.setPhone(companyData[0]);
        companyModel.setAd(companyData[3]);
        companyModel.setCpy_intro(companyData[11]);
        companyModel.setEmail(companyData[8]);
        companyModel.setFax(companyData[9]);
        companyModel.setWebsite(companyData[10]);
        companyModel.setIntro(companyData[7]);
        companyModel.setWork_time(companyData[6]);
        companyModel.setEnglish_name(companyData[5]);
        companyModel.setAddress(companyData[1]);
//        System.out.println(companyModel.toString());
        return companyModel;//返回封装好的model类
    }

    public static void main(String[] args) {
        new CompanyService().getCompany();
    }
}
